//
//  CommitDataViewController.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/7/31.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "CommitDataViewController.h"
#import "CommitDataCell.h"
#import "CommitDataBottomCell.h"
#import "AddressManagerViewController.h"
#import "SignUpInformationViewController.h"
#import "AddressModel.h"
#import "InstituSubmiteOverView.h"
#import "DisclaimerView.h"
#import "CommitDataLaterAddCell.h"
@interface CommitDataViewController ()<UITableViewDelegate,UITableViewDataSource,UIActionSheetDelegate,UIImagePickerControllerDelegate,UIViewControllerTransitioningDelegate,UITextFieldDelegate,UITextViewDelegate>

@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSArray *titlesArra;
@property(nonatomic,strong)UIImageView *centerImageview;
@property(nonatomic,strong)UIActionSheet *actionSheet;
@property(nonatomic,copy)NSString *pictureId;
@property(nonatomic,copy)NSString *addressId;
@property(nonatomic,copy)NSString *phoneNumber;
@property(nonatomic,strong)UIButton *chooesBtn;
@property(nonatomic,strong)UIView *backView;
@property(nonatomic,strong)InstituSubmiteOverView *submitView;
@property(nonatomic,strong)NSArray *placeholderArray;
@property(nonatomic,strong)DisclaimerView *disclamerview;
@property(nonatomic,copy)NSString *matchRecordId;
@end

@implementation CommitDataViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"填写报名信息";
    [self createUI];
    // Do any additional setup after loading the view.
}
-(void)createUI{
////图片的上部分
//    UILabel *titleLabel = [[UILabel alloc] init];
//    titleLabel.adjustsFontSizeToFitWidth = YES;
//    titleLabel.text = @"上传比赛作品";
//    titleLabel.textAlignment = NSTextAlignmentCenter;
//    [self.view addSubview:titleLabel];
//    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.equalTo(self.view.mas_centerX);
//        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(140));
//        make.height.mas_equalTo(scaleTopAndBottom(30));
//        make.top.equalTo(self.view.mas_top).offset(scaleTopAndBottom(74));
//    }];
//    UIImageView *leftView = [[UIImageView alloc] init];
//    [self.view addSubview:leftView];
//    [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(125));
//        make.top.equalTo(self.view.mas_top).offset(scaleTopAndBottom(84));
//        make.size.mas_equalTo(CGSizeMake(10, 10));
//    }];
//    UIImageView *rightView = [[UIImageView alloc] init];
//    [self.view addSubview:rightView];
//    [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-125));
//        make.top.equalTo(self.view.mas_top).offset(scaleTopAndBottom(84));
//        make.size.mas_equalTo(CGSizeMake(10, 10));
//    }];
//    _centerImageview = [[UIImageView alloc] init];
//    _centerImageview.image = [UIImage imageNamed:@"大"];
//    [self.view addSubview:_centerImageview];
//    [_centerImageview mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(10));
//        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-10));
//        make.top.equalTo(titleLabel.mas_bottom).offset(scaleLeftAndRight(10));
//        make.height.mas_equalTo(scaleTopAndBottom(175));
//    }];
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPickPicture:)];
//    [_centerImageview addGestureRecognizer:tap];
//    _centerImageview.userInteractionEnabled = YES;
////图片的下部分
//    UILabel *titleLabel1 = [[UILabel alloc] init];
//    titleLabel1.text = @"填写报名信息";
//    titleLabel1.adjustsFontSizeToFitWidth = YES;
//    titleLabel1.textAlignment = NSTextAlignmentCenter;
//    [self.view addSubview:titleLabel1];
//    [titleLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.equalTo(self.view.mas_centerX);
//        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(140));
//        make.height.mas_equalTo(scaleTopAndBottom(30));
//        make.top.equalTo(_centerImageview.mas_bottom).offset(scaleTopAndBottom(10));
//    }];
//    UIImageView *leftView1 = [[UIImageView alloc] init];
//    [self.view addSubview:leftView1];
//    [leftView1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.view.mas_left).offset(scaleLeftAndRight(125));
//        make.top.equalTo(_centerImageview.mas_bottom).offset(scaleTopAndBottom(20));
//        make.size.mas_equalTo(CGSizeMake(10, 10));
//    }];
//    UIImageView *rightView1 = [[UIImageView alloc] init];
//    [self.view addSubview:rightView1];
//    [rightView1 mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.equalTo(self.view.mas_right).offset(scaleLeftAndRight(-125));
//        make.top.equalTo(_centerImageview.mas_bottom).offset(scaleTopAndBottom(20));
//        make.size.mas_equalTo(CGSizeMake(10, 10));
//    }];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT - 64) style:UITableViewStyleGrouped];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[CommitDataCell class] forCellReuseIdentifier:@"CommitDataCell"];
    [self.tableView registerClass:[CommitDataBottomCell class] forCellReuseIdentifier:@"CommitDataBottomCell"];
    [self.tableView registerClass:[CommitDataLaterAddCell class] forCellReuseIdentifier:@"CommitDataLaterAddCell"];
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        
        // Fallback on earlier versions
    }
}
-(void)agreeOrNotAgree:(UIButton *)btn{
    btn.selected = !btn.selected;
    if (btn.selected) {
        
    }else{

    }
}
#pragma mark -tablview的代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 1) {
        return self.titlesArra.count;
    }else{
        return 1;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 1) {
        CommitDataCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CommitDataCell"];
        cell.textfield.delegate = self;
        cell.textfield.textAlignment = NSTextAlignmentRight;
        [cell.textfield setAutoAdjust:YES];
        cell.labell.text = self.titlesArra[indexPath.row];
        if (indexPath.row == 2 || indexPath.row == 3) {
            cell.ImageView.hidden = YES;
        }
        return cell;
    }else if(indexPath.section == 2){
        CommitDataBottomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CommitDataBottomCell"];
        cell.ImageView.image = [UIImage imageNamed:@"redredStt.png"];
        return cell;
    }else{
        CommitDataLaterAddCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CommitDataLaterAddCell"];
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPickPicture:)];
            [cell.centerImageview addGestureRecognizer:tap];
        cell.descriptextVeiw.delegate = self;
        
        return cell;
    }


}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return scaleTopAndBottom(390);
    }else if(indexPath.section == 1){
        return scaleTopAndBottom(45);
    }else{
       return scaleTopAndBottom(60);
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor whiteColor];
    return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.000001f;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor whiteColor];
    if (section == 2) {
        
        self.chooesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.chooesBtn setBackgroundImage:[UIImage imageNamed:@"圆角矩形-3"] forState:UIControlStateNormal];
        [self.chooesBtn setBackgroundImage:[UIImage imageNamed:@"对号-(3)"] forState:UIControlStateSelected];
        [self.chooesBtn addTarget:self action:@selector(agreeOrNotAgree:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:self.chooesBtn];
        
        [self.chooesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_left).offset(scaleLeftAndRight(15));
            make.top.equalTo(view.mas_top).offset(scaleTopAndBottom(10));
            make.size.mas_equalTo(CGSizeMake(15, 15));
        }];
        UILabel *readLabel = [[UILabel alloc] init];
        [view addSubview:readLabel];
        readLabel.text = @" 我已阅读并同意";
        readLabel.adjustsFontSizeToFitWidth = YES;
        readLabel.textAlignment = NSTextAlignmentCenter;
        [readLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.chooesBtn.mas_right).offset(scaleLeftAndRight(0));
            make.top.equalTo(view.mas_top).offset(scaleTopAndBottom(10));
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(120), scaleTopAndBottom(15)));
        }];
        UIButton *introdBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        introdBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
        [introdBtn setTitle:@"免责声明" forState:UIControlStateNormal];
        [introdBtn addTarget:self action:@selector(showDiscalView:) forControlEvents:UIControlEventTouchUpInside];
        [introdBtn setTitleColor:COLOR_HEX(0xF9D025) forState:UIControlStateNormal];
        [view addSubview:introdBtn];
        [introdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(readLabel.mas_right).offset(scaleLeftAndRight(0));
            make.top.equalTo(view.mas_top).offset(scaleTopAndBottom(10));
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(80), scaleTopAndBottom(15)));
        }];
        UIButton *commitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [commitBtn setTitle:@"提交资料" forState:UIControlStateNormal];
        commitBtn.backgroundColor = COLOR_HEX(0xF9D025);
        commitBtn.layer.cornerRadius = scaleTopAndBottom(20);
        commitBtn.layer.masksToBounds = YES;
        [commitBtn addTarget:self action:@selector(goToSignupInformationPage:) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:commitBtn];
        [commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_left).offset(scaleLeftAndRight(15));
            make.top.equalTo(readLabel.mas_bottom).offset(scaleTopAndBottom(20));
            make.right.equalTo(view.mas_right).offset(scaleLeftAndRight(-15));
            make.height.mas_equalTo(scaleTopAndBottom(40));
        }];
        
    }
      return view;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 2) {
        return scaleTopAndBottom(105);
    }
    return 0.000001f;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0 || indexPath.section == 1) {
        
    }else{
        AddressManagerViewController *addressVc = [[AddressManagerViewController alloc] init];
        addressVc.addressBlock = ^(AddressModel *model) {
            CommitDataBottomCell *cell = [tableView cellForRowAtIndexPath:indexPath];
            cell.namelabell.text = [NSString stringWithFormat:@"%@    %@",model.collectName,model.phoneNumber];
            cell.adresslabell.text = [NSString stringWithFormat:@"%@%@%@%@",model.province,model.city,model.area,model.address];
            self.addressId = model.Id;
            self.phoneNumber = model.phoneNumber;
            
        };
        [self.navigationController pushViewController:addressVc animated:YES];
    }
}
-(NSArray *)titlesArra{
    if (_titlesArra == nil) {
        _titlesArra = @[@"作品名称",@"宝宝姓名",@"指导老师",@"推选机构"];
        
    }
    return _titlesArra;
}

#pragma mark -点击上传营业执照图片的手势
-(void)gotoPickPicture:(UITapGestureRecognizer *)tap{
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
        self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"选择图像" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照", @"从相册选择",  nil];
    }else{
        self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"选择图像" delegate:self cancelButtonTitle:@"取消"destructiveButtonTitle:nil otherButtonTitles:@"从相册选择", nil];
    }
    
    self.actionSheet.tag = 10000;
    [self.actionSheet showInView:self.view];
    
}
#pragma mark - 调用相机的代理方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (actionSheet.tag == 10000) {
        NSUInteger sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        // 判断是否支持相机
        if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            switch (buttonIndex) {
                case 0:
                    //来源:相机
                    sourceType = UIImagePickerControllerSourceTypeCamera;
                    break;
                case 1:
                    //来源:相册
                    sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
                    break;
                case 2:
                    return;
            }
        }
        else {
            if (buttonIndex == 2) {
                return;
            } else {
                sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
            }
        }
        // 跳转到相机或相册页面
        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
        imagePickerController.delegate = (id)self;
        imagePickerController.allowsEditing = YES;
        imagePickerController.sourceType = sourceType;
        imagePickerController.transitioningDelegate = self;
        imagePickerController.modalPresentationStyle = UIModalPresentationCustom;
        [self presentViewController:imagePickerController animated:YES completion:nil];
    }
}
//报名信息页面的点击事件
-(void)goToSignupInformationPage:(UIButton *)btn{
    NSIndexPath *index1 = [NSIndexPath indexPathForRow:0 inSection:1];
    CommitDataCell *cell1 = [self.tableView cellForRowAtIndexPath:index1];
    NSIndexPath *index2 = [NSIndexPath indexPathForRow:1 inSection:1];
    CommitDataCell *cell2 = [self.tableView cellForRowAtIndexPath:index2];
    NSIndexPath *index3 = [NSIndexPath indexPathForRow:2 inSection:1];
    CommitDataCell *cell3 = [self.tableView cellForRowAtIndexPath:index3];
    NSIndexPath *index4 = [NSIndexPath indexPathForRow:3 inSection:1];
    CommitDataCell *cell4 = [self.tableView cellForRowAtIndexPath:index4];
    NSUserDefaults *sessionId = [[NSUserDefaults standardUserDefaults] objectForKey:@"sessionId"];
    CommitDataLaterAddCell *cell11 = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    NSString *desciptionStr = cell11.descriptextVeiw.text;

    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *url = ServerIp@"/matchApp/signUpMatch";
    if (self.pictureId && cell1.textfield.text && cell2.textfield.text  && self.addressId ) {
        NSDictionary *param = [NSDictionary dictionaryWithObjectsAndKeys:sessionId,@"sessionId",self.pictureId,@"file.id",cell1.textfield.text,@"babyName",self.addressId,@"address.id",self.matchId,@"match.id",cell3.textfield.text,@"teacher",cell4.textfield.text,@"electInstitution",cell1.textfield.text,@"name",desciptionStr,@"txt", nil];
        NSLog(@"参数的值%@",param);
        [manager POST:url parameters:param progress:^(NSProgress * _Nonnull uploadProgress) {
            
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
            self.matchRecordId = jsonDic[@"matchRecord"][@"id"];
            NSLog(@"返回的字典信息%@",jsonDic);
            NSLog(@"%@",jsonDic[@"msg"]);
        [self showRewardView];

        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            
        }];

    }else{
//          [self showRewardView];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"带有*号为必填项" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }
    


}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self dismissViewControllerAnimated:YES completion:nil];
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    CommitDataLaterAddCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    cell.centerImageview.image = image;
    [cell.centerImageview setContentScaleFactor:[[UIScreen mainScreen] scale]];
    cell.centerImageview.contentMode =  UIViewContentModeScaleAspectFill;
    cell.centerImageview.clipsToBounds = YES;
    [self getFilePictureIdWithImage:image];
}

/**
 获取到文件的fileID
 */
-(void)getFilePictureIdWithImage:(UIImage *)image{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    NSString *url = PictureIp@"/file/fileUpload";
    [manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        NSData *imageData = UIImagePNGRepresentation(image);
        [formData appendPartWithFileData:imageData name:@"file" fileName:@"producction.png" mimeType:@"application/octet-stream"];
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"获取到的数据%@",dict);
        self.pictureId = dict[@"id"];
        NSLog(@"获取到的图片的ID%@",self.pictureId);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];

}

//缩放图片到指定大小的imageview
- (UIImage*)imageCompressWithSimple:(UIImage*)image scaledToSize:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0,0,size.width,size.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}
#pragma mark -textfile的代理方法
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}
-(void)textViewDidChange:(UITextView *)textView{
    CommitDataLaterAddCell *cell  = (CommitDataLaterAddCell *)[[textView superview] superview];
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    NSLog(@"这是第%ld组%ld行",(long)indexPath.section,(long)indexPath.row);
    if (indexPath.section == 0) {
        cell.placeHolder.hidden = YES;
        
        //允许提交按钮点击操作
        cell.placeHolder.hidden = YES;
        //实时显示字数
        NSLog(@"点击了");
        cell.stirngLenghLabel.text = [NSString stringWithFormat:@"%lu/255", (unsigned long)textView.text.length];
        
        //字数限制操作
        
        if (textView.text.length >= 500) {
            
            textView.text = [textView.text substringToIndex:500];
            
            cell.stirngLenghLabel.text = @"500/500";
            
        }
        
        //取消按钮点击权限，并显示提示文字
        
        if (textView.text.length == 0) {
            
            cell.placeHolder.hidden = NO;
        }
    }else{
        
        if (textView.text.length == 0) {
            UILabel *label = [textView viewWithTag:1000010];
            label.hidden = NO;
        } else {
            NSLog(@"就这样吧");
            UILabel *label = [textView viewWithTag:1000010];
            label.hidden = YES;
        }
        
    }
}
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
    if ([text isEqualToString:@"\n"]){ //判断输入的字是否是回车，即按下return
        //在这里做你响应return键的代码
        [textView resignFirstResponder];
        return NO; //这里返回NO，就代表return键值失效，即页面上按下return，不会出现换行，如果为yes，则输入页面会换行
    }else{
        return YES;
    }
}
-(void)showRewardView{
    
    self.backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
   self.backView.alpha = 0.5f;
    self.backView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:self.backView];
    self.submitView = [[InstituSubmiteOverView alloc] initWithFrame:CGRectZero];
    _submitView.imageV.image = [UIImage imageNamed:@"组-3"];
    [self.view addSubview:_submitView];
    [_submitView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(0, 0));
    }];
    [UIView animateWithDuration:1.0f animations:^{
        [_submitView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(265.f, 300.f));
        }];
        
    }];
    UITapGestureRecognizer *tapss = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapViewToSure:)];
    UIView *sureView = [[UIView alloc] init];
    [_submitView addSubview:sureView];
    [sureView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(_submitView);
        make.height.mas_equalTo(50);
    }];
    [sureView addGestureRecognizer:tapss];
    
    UITapGestureRecognizer *tapdd = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removebackView:)];
    UIView *deletedView = [[UIView alloc] init];
    [_submitView addSubview:deletedView];
    [deletedView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.equalTo(_submitView);
        make.size.mas_equalTo(CGSizeMake(40, 40));
    }];
    [deletedView addGestureRecognizer:tapdd];
}
-(void)tapViewToSure:(UITapGestureRecognizer *)tap{
    [UIView animateWithDuration:0.1 animations:^{
        [self.backView removeFromSuperview];
        [_submitView removeFromSuperview];
    }];
    SignUpInformationViewController *signInforVc = [[SignUpInformationViewController alloc] init];
    NSIndexPath *index1 = [NSIndexPath indexPathForRow:0 inSection:1];
    CommitDataCell *cell1 = [self.tableView cellForRowAtIndexPath:index1];
    NSIndexPath *index2 = [NSIndexPath indexPathForRow:1 inSection:1];
    CommitDataCell *cell2 = [self.tableView cellForRowAtIndexPath:index2];
        CommitDataBottomCell *cell3 = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:2]];
    CommitDataLaterAddCell *cell4 = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    signInforVc.productImage = cell4.centerImageview.image;
    signInforVc.fileName = cell1.textfield.text;
    signInforVc.phoneNumber = self.phoneNumber;
    signInforVc.babyName = cell2.textfield.text;
    signInforVc.matchStartTime = self.matchStarttime;
    signInforVc.addressStr = cell3.adresslabell.text;
    signInforVc.themeTitle = self.themeTitle;
    signInforVc.matchRecordId = self.matchRecordId;
    [self.navigationController pushViewController:signInforVc animated:YES];
    NSLog(@"你点击了确定的部分");
}
-(void)removebackView:(UITapGestureRecognizer *)tap{
    
    [UIView animateWithDuration:0.1 animations:^{
//        UIView *view = tap.view;
        [self.backView removeFromSuperview];
        [_submitView removeFromSuperview];
    }];
}
-(NSArray *)placeholderArray{
    if (_placeholderArray == nil) {
        _placeholderArray = @[@"请输入作品名称",@"请输入您的姓名",@"请输入您的指导老师的姓名",@"请输入您的指导机构"];
    }
    return _placeholderArray;
}
/**
 免责声明
 
 */
-(void)showDiscalView:(UIButton *)btn{
    UIView *backView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    backView.alpha = 0.5f;
    backView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:backView];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removesbackView:)];
    [backView addGestureRecognizer:tap];
    self.disclamerview = [[DisclaimerView alloc] initWithFrame:CGRectZero];
    self.disclamerview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.disclamerview];
    [self.disclamerview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(0, 0));
    }];
    [UIView animateWithDuration:1.0f animations:^{
        [self.disclamerview mas_updateConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(350), scaleTopAndBottom(500)));
        }];
        
    }];
}
-(void)removesbackView:(UITapGestureRecognizer *)tap{
    
    [UIView animateWithDuration:0.1 animations:^{
        UIView *view = tap.view;
        [view removeFromSuperview];
        [_disclamerview removeFromSuperview];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
